<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>仓库管理</title>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<style type="text/css">
#searchbar{
   margin-bottom: 10px;
   margin-left:15px;
  }
  .navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.l-button-search {
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
</style>
</head>

<body style="padding:6px; overflow:hidden;">
<div class="navbar">
		<span>您当前的位置：</span>
		基础数据管理 &gt; 仓库管理
</div>
<div id="wharehouselist" style="margin:0; padding:0"></div>
  <div style="display:none;">
  <!-- g data total ttt -->
</div>

<script>
    var basePath='${BasePath}';
    
    var grid = null;
    $(function () {
    	
        
    	grid = $("#wharehouselist").ligerGrid({
            columns: [
            { display: '仓库编码', name: 'whNo'},
            { display: '仓库名称', name: 'whName'},
            { display: '联系电话', name: 'whPhone'},
            { display: '联系人', name: 'whUser'},
            { display: '仓库地址', name: 'whAdderss'},
            { display: '库存类型', name: 'whType',render:function(column,rowindex,value){
            	return value==2?"虚库":"实库";
            } },
            { display: '操作',render:function(column,rowindex,value){
            	var h="";
            	h+="<a href='javascript:editWhareHouse("+rowindex+")' >修改</a>";
            	h+="　　";
            	h+="<a href='javascript:deleteWhareHouse("+rowindex+")' >删除</a>";
            	return h;
            } }
            ], 
            pageSize:20,
            width: '100%',
            height: '100%',
            dataType: 'server', 
            dataAction: 'server',
            pagesizeParmName: 'pageSize',
            parms: [       
            	],
            url: "ajaxWhareHouseList.do",
            toolbar: {items: [{ text: "新增仓库", click: addWhareHouse, icon: "add" }]}
        });
    
    });
    
    function addWhareHouse(){
    	 var whNo='--';
    	 var m=$.ligerDialog.open({title:'新增仓库',url:'${BasePath}/base/wharehouse/'+whNo+'/editWhareHouse.do',height:350,width:600,isResize: false, isDrag: false });
     	  m.show(); 
    }
    
    function editWhareHouse(rowindex){
  	  var whNo=grid.getData()[rowindex].id;
  	  var m=$.ligerDialog.open({title:'修改仓库',url:'${BasePath}/base/wharehouse/'+whNo+'/editWhareHouse.do',height:350,width:600,isResize: false, isDrag: false });
  	  m.show(); 
    }

    function deleteWhareHouse(rowindex){
    	var whNo=grid.getData()[rowindex].whNo;
    	$.ligerDialog.confirm('是否删除此仓库信息', function (yes) { if(yes){
    		$.ajax({
    	 		   type: "POST",
    	 		   url: "ajaxToDeleteWhareName.do",
    	 		   data: "whNo="+whNo,
    	 		   success: function(msg){
    					if(msg=='error'){
    						  var s=window.parent.$.ligerDialog.warn("存在数据关联不允许删除","提示",function(item, Dialog, index) {
					          		window.location.href = basePath+'/base/wharehouse/toWhareHouseList.do';
					          		});
					          		$(s.dialog.winbtns).remove(); 
    					}else{
    						window.parent.f_tip('仓库信息删除成功');
    						window.location.href=window.location.href;
    					}
    	 		   }
    	 		});
	    		
	    	} });	
    }  
   
  
</script>
</body>
</html>